package com.hui.dao;

import com.hui.entity.Category;
import com.hui.entity.WareHouse;
import com.hui.mapper.CategoryMapper;
import com.hui.mapper.WareHouseMapper;
import com.hui.util.DruidUtil;

import java.util.List;

/**
 * @Description
 * @date 2023/2/11 8:48
 */
public class WareHouseDao {

    /**
     * 查询全部仓库数据
     **/
    public List<WareHouse> findWareHouseAll() {
        String sql = "select  * from tb_warehouse ";
        return DruidUtil.commonFindListByParam(sql, new WareHouseMapper());
    }

    /**
     * 新增仓库数据
     **/
    public void insertWareHouse(WareHouse wareHouse) {
        String sql = "insert into tb_warehouse values(null,?,?,?,?) ";
        DruidUtil.commonUpdate(sql, wareHouse.getWarehouseName(), wareHouse.getWarehouseAddr(), wareHouse.getWarehouseDesc(), wareHouse.getStatus());
    }

    /**
     * 删除仓库数据
     **/
    public void delWareHouseById(int id) {
        String sql = "delete from tb_warehouse where warehouseId=? ";
        DruidUtil.commonUpdate(sql, id);
    }

    /**
     * 根据id查询数据
     **/
    public WareHouse findWareHouseById(int id) {
        String sql = "select  * from tb_warehouse  where warehouseId=?";
        return DruidUtil.commonFindObjectByParam(sql, new WareHouseMapper(), id);
    }

    /**
     * 修改数据
     **/
    public void updateWareHouseById(WareHouse wareHouse) {
        String sql = "update  tb_warehouse set warehouseName=?,warehouseAddr=?,warehouseDesc=? where warehouseId=? ";
        DruidUtil.commonUpdate(sql, wareHouse.getWarehouseName(), wareHouse.getWarehouseAddr(), wareHouse.getWarehouseDesc(), wareHouse.getWarehouseId());
    }


}
